<?php
namespace App\Models\Relations;

/**
 *
 * @author Joker
 *        
 */
trait TeachesTrait
{
    
    
    public function teachesed()
    {
        $query = $this->newQuery()->where($this->getKeyName(), $this->getKey());
        
        $this->{$this->getTeachesAtColumn()} = $time = $this->freshTimestamp();
        
        $query->update([$this->getTeachesAtColumn() => $this->fromDateTime($time),$this->getStatusColumn() => $this->is_teaches]);
    }
    
    /**
     * Get the name of the "validated at" column.
     *
     * @return string
     */
    public function getTeachesAtColumn()
    {
        return defined('static::TEACHES_AT') ? static::TEACHES_AT : 'teaches_at';
    }
    
    /**
     * 获取 是否 已审核 字段
     * @return string 
     */
    public function getStatusColumn()
    {
        return defined('static::IS_TEACHES') ? static::IS_TEACHES : 'is_teaches';
    }
}